package com.ruoyi.slope.data.soil.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.slope.data.soil.mapper.SlopeSoilDataMapper;
import com.ruoyi.slope.data.soil.domain.SlopeSoilData;
import com.ruoyi.slope.data.soil.service.ISlopeSoilDataService;

/**
 * 土壤温度和水分占比监测数据Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-18
 */
@Service
public class SlopeSoilDataServiceImpl implements ISlopeSoilDataService 
{
    @Autowired
    private SlopeSoilDataMapper slopeSoilDataMapper;

    /**
     * 获取最新土壤含水率
     */
    @Override
    public SlopeSoilData getLatestSoilMoisture(String deviceSn) {
        return slopeSoilDataMapper.selectLatestSoilMoisture(deviceSn);
    }

    /**
     * 获取最新土壤温度
     */
    @Override
    public SlopeSoilData getLatestSoilTemperature(String deviceSn) {
        return slopeSoilDataMapper.selectLatestSoilTemperature(deviceSn);
    }

    /**
     * 查询土壤温度和水分占比监测数据
     * 
     * @param id 土壤温度和水分占比监测数据主键
     * @return 土壤温度和水分占比监测数据
     */
    @Override
    public SlopeSoilData selectSlopeSoilDataById(Long id)
    {
        return slopeSoilDataMapper.selectSlopeSoilDataById(id);
    }

    /**
     * 查询土壤温度和水分占比监测数据列表
     * 
     * @param slopeSoilData 土壤温度和水分占比监测数据
     * @return 土壤温度和水分占比监测数据
     */
    @Override
    public List<SlopeSoilData> selectSlopeSoilDataList(SlopeSoilData slopeSoilData)
    {
        return slopeSoilDataMapper.selectSlopeSoilDataList(slopeSoilData);
    }

    /**
     * 新增土壤温度和水分占比监测数据
     * 
     * @param slopeSoilData 土壤温度和水分占比监测数据
     * @return 结果
     */
    @Override
    public int insertSlopeSoilData(SlopeSoilData slopeSoilData)
    {
        slopeSoilData.setCreateTime(DateUtils.getNowDate());
        return slopeSoilDataMapper.insertSlopeSoilData(slopeSoilData);
    }

    /**
     * 修改土壤温度和水分占比监测数据
     * 
     * @param slopeSoilData 土壤温度和水分占比监测数据
     * @return 结果
     */
    @Override
    public int updateSlopeSoilData(SlopeSoilData slopeSoilData)
    {
        slopeSoilData.setUpdateTime(DateUtils.getNowDate());
        return slopeSoilDataMapper.updateSlopeSoilData(slopeSoilData);
    }

    /**
     * 批量删除土壤温度和水分占比监测数据
     * 
     * @param ids 需要删除的土壤温度和水分占比监测数据主键
     * @return 结果
     */
    @Override
    public int deleteSlopeSoilDataByIds(Long[] ids)
    {
        return slopeSoilDataMapper.deleteSlopeSoilDataByIds(ids);
    }

    /**
     * 删除土壤温度和水分占比监测数据信息
     * 
     * @param id 土壤温度和水分占比监测数据主键
     * @return 结果
     */
    @Override
    public int deleteSlopeSoilDataById(Long id)
    {
        return slopeSoilDataMapper.deleteSlopeSoilDataById(id);
    }
}
